package com.example.lenovo.appstore.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SaveAndGetData {

    private final static String name = "config";
    private final static int mode = Context.MODE_PRIVATE;
    public static final String isEnglish = "isEnglish";//0：中文  1：英文
    public static final String token = "TOKEN";
    public static final String User_tel = "USER_TEL";
    public static final String User_id = "USER_ID";
    public static final String User_nickname = "User_nickname";

    public static final String IS_ENGLISH = "IS_ENGLISH";//0:繁體中文  1：英文

    public static void saveInt(Context context, String key, int value) {
        SharedPreferences sp = context.getSharedPreferences(name, mode);
        SharedPreferences.Editor edit = sp.edit();
        edit.putInt(key, value);
        edit.commit();
    }

    public static void saveString(Context context, String key, String value) {
        SharedPreferences sp = context.getSharedPreferences(name, mode);
        SharedPreferences.Editor edit = sp.edit();
        edit.putString(key, value);
        edit.commit();
    }

    public static int getInt(Context context, String key, int defValue) {
        SharedPreferences sp = context.getSharedPreferences(name, mode);
        return sp.getInt(key, defValue);
    }

    public static String getString(Context context, String key, String defValue) {
        SharedPreferences sp = context.getSharedPreferences(name, mode);
        return sp.getString(key, defValue);
    }

}
